package com.bl.weilan.dao.redis;

import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;

/**
 * Created by liangweikang on 2017/6/11.
 */
@Service
@Log4j2
public class MessageDao extends AbstractDao {

    private final String AUTH_CODE_PREFIX = "AUTH_CODE_";

    public void setAuthCode(String phone, String code, long duration) {
        set(genKey(AUTH_CODE_PREFIX, phone), code, duration);
    }

    public String getAuthCode(String phone) {
        return get(genKey(AUTH_CODE_PREFIX, phone));
    }

    public long getAuthCodeExpire(String phone) {
        return pttl(genKey(AUTH_CODE_PREFIX, phone));
    }

}
